package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.service.ApArticleConfigService;
import com.heima.model.article.pojos.ApArticleConfig;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author Du leilei
 * @version 1.0
 * @Description
 * @createTime 2023年09月04日 11:29:00
 */
@Service
public class ApArticleConfigServiceImpl extends ServiceImpl<ApArticleConfigMapper, ApArticleConfig> implements ApArticleConfigService {
    /**
     * 文章上下架
     *
     * @param map
     */
    @Override
    public void isDown(Map map) {

        String articleId = String.valueOf(map.get("articleId"));
        String enable = String.valueOf(map.get("enable"));

        boolean isDown = true;

        if (enable.equals("1")){
            isDown=false;
        }

        update(Wrappers.<ApArticleConfig>lambdaUpdate().set(ApArticleConfig::getIsDown,isDown).eq(ApArticleConfig::getArticleId,articleId));
    }
}
